<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>支付页面</title>
    <link rel="stylesheet" th:href="@{/static/layui/css/layui.css}">
    <script th:src="@{/static/jquery-2.1.4.js}" type="text/javascript" charset="utf-8"></script>
    <script th:src="@{/static/layui/layui.js}" type="text/javascript" charset="utf-8"></script>
    <script th:src="@{/static/mylayer.js}" type="text/javascript" charset="utf-8"></script>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 20px;
        }

        .container {
            max-width: 600px;
            margin: auto;
            background: white;
            padding: 20px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }

        header {
            text-align: center;
            margin-bottom: 20px;
        }

        .logo {
            width: 200px;
        }

        .payment-info {
            text-align: center;
        }

        .amount {
            font-size: 24px;
            color: #333;
        }

        .qrcode-container {
            margin: 20px 0;
        }

        .order-details h1, .order-details h2 {
            text-align: center;
            color: #555;
        }

        .payment-instructions {
            text-align: center;
            margin-top: 20px;
        }

        .btn-success {
            background-color: #4CAF50;
            color: white;
            border: none;
            padding: 10px 20px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 16px;
            margin: 4px 2px;
            cursor: pointer;
            border-radius: 5px;
        }

        .payment-instructions {
            text-align: center;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: row;
        }

        .instruction-image {
            width: 50px;
            margin-right: 10px; /* 适当调整间距 */
        }

        .btn-success {
            margin-left: 10px; /* 适当调整间距 */
        }

        .btn-cancel {
            background-color: #f44336;
            color: white;
            border: none;
            padding: 10px 20px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 16px;
            margin: 4px 2px;
            cursor: pointer;
            border-radius: 5px;
        }

        .btn-cancel {
            margin-left: 10px; /* 适当调整间距 */
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <img src="/static/pic/zfb.png" class="logo">
        </header>

        <div class="payment-info">
            <div class="amount">￥<span id="payment"></span></div>
            <div class="qrcode-container">
                <img id="show_qrcode" src="/static/pic/zfbm.jpg" title="请尽快支付" style="height: 300px; width: 300px">
            </div>
            <div class="order-details">
                <h2>订单号:<em id="orderNo"></em></h2>
            </div>

        </div>

        <div class="payment-instructions">
            <img src="/static/pic/zfbsao.png" class="instruction-image" >
            <p id="showtext">打开支付宝 [扫一扫]</p>
            <button id="cancelPayment" class="btn-cancel">取消付款</button>
            <button id="payOrderSuccess" class="btn-success">支付成功</button>
        </div>
    </div>

    <script type="text/javascript">
        var queryString = window.location.search;
        var urlParams = new URLSearchParams(queryString);
        var orderNo = urlParams.get("orderNo");

        $("#orderNo").text(orderNo);
        $('#cancelPayment').click(function() {
            layer.confirm(
                '您确定要取消付款吗？',
                {icon : 3},
                function (index) {
                    history.back();
                }
            )

        });
        $('#payOrderSuccess').click(function() {
            $.post(
                '/order/payOrderSuccess',
                {'orderNo': orderNo},
                function (result) {
                    if (result.code == 0) {
                        mylayer.okUrl(result.msg, '/page/order/detail?orderNo='+orderNo+'')
                    }
                },
                'json'
            );

        });
        $.post(
            '/order/orderByOrderNo',
            {'orderNo': orderNo},
            function (result) {
                if (result.code == 0) {
                    $("#payment").text(result.data.payment);
                }
            },
            'json'
        );
    </script>
</body>
</html>
